#include <bits/stdc++.h>

using namespace std;

class MedianFinder {
    priority_queue<int,vector<int>,less<int>> max_heap;
    priority_queue<int,vector<int>,greater<int>> min_heap;
public:
    /** initialize your data structure here. */
    MedianFinder() {
        
    }
    
    void addNum(int num) {
        int len_max=max_heap.size(),len_min=min_heap.size();
        int len=len_max+len_min;
        if(len&1){
            //总个数是奇数个，给他扔到大顶堆里
            //为了确保顺序，需调整num
            if(len_min>0 && min_heap.top()<num){
                int tmp=min_heap.top();
                min_heap.pop();
                min_heap.push(num);
                num=tmp;
            }
            max_heap.push(num);
        }else{
            //总个数是偶数个，给他扔到小顶堆里
            //同理
            if(len_max>0 && max_heap.top()>num){
                int tmp=max_heap.top();
                max_heap.pop();
                max_heap.push(num);
                num=tmp;
            }
            min_heap.push(num);          
        }
    }
    
    double findMedian() {
        int len_max=max_heap.size(),len_min=min_heap.size();
        int len=len_max+len_min;
        if(len&1){
            return min_heap.top();
        }else{
            return (min_heap.top()+max_heap.top())/2.0;
        }
    }
};

/**
 * Your MedianFinder object will be instantiated and called as such:
 * MedianFinder* obj = new MedianFinder();
 * obj->addNum(num);
 * double param_2 = obj->findMedian();
 */


int main(){




    return 0;
}